package org.netty.framework.core.concurrent;

/**
 * web socket 业务线程池
 * 
 * @author chenfanglin
 * @date 2018年10月9日下午4:22:27
 */
public class WebSocketServerThreadPoolExecutor extends AbstractNettyThreadPool {

	private NettyServerThreadPoolExecutor nettyServerThreadPoolExecutor;

	private WebSocketServerThreadPoolExecutor() {
	}

	private static class WebSocketServerThreadPoolExecutorHolder {
		private static final WebSocketServerThreadPoolExecutor WEB_SOCKET_SERVER_THREADPOOL_EXECUTOR = new WebSocketServerThreadPoolExecutor();
	}

	public static WebSocketServerThreadPoolExecutor getInstance() {
		return WebSocketServerThreadPoolExecutorHolder.WEB_SOCKET_SERVER_THREADPOOL_EXECUTOR;
	}

	@Override
	public void createThreadPoolExecutor() {
		this.nettyServerThreadPoolExecutor = super.createThreadPoolExecutor("web-socket-server");
	}

	@Override
	public NettyServerThreadPoolExecutor getThreadPoolExecutor() {
		if (this.nettyServerThreadPoolExecutor == null) {
			createThreadPoolExecutor();
		}
		return this.nettyServerThreadPoolExecutor;
	}

}
